<template>
	<!-- 明细 -->
  <div class="stu">
	<el-dialog width='50%' title="明细" :visible.sync="dialogTableVisible" top='3vh'>
		
	   <el-table v-if='num==1' v-loading='logins' :data="tableData" width='100%' height='625' stripe style="width: 100%">
		 <el-table-column header-align='center' align='center' prop="indoor_hygiene_score" label="屋内卫生得分" >
			 <template slot-scope="scope">{{scope.row.indoor_hygiene_score/2}}</template>
		 </el-table-column>
		 <el-table-column header-align='center' align='center' prop="outdoor_hygiene_score" label="屋外卫生得分" >
			 <template slot-scope="scope">{{scope.row.outdoor_hygiene_score/2}}</template>
		 </el-table-column>
		 <el-table-column header-align='center' align='center' prop="" label="图片" >
			 <template slot-scope="scope">
			 	  <p @click='selectimg(scope.row)' v-if="scope.row.img_list">
					  <el-avatar v-show='imgjoin(scope.row.img_list)[0]' shape="square" :size="100" fit="fill" :src="imgjoin(scope.row.img_list)[0]"></el-avatar>
				  </p>
			 </template>
		 </el-table-column>
		 <el-table-column header-align='center' align='center' prop="comment" label="评语" ></el-table-column>
		 <el-table-column header-align='center' align='center' prop="time" label="时间" ></el-table-column>
	   </el-table>
	   
	   <el-table v-else v-loading='logins' :data="tableData" width='100%' height='625' stripe style="width: 100%">
	   		 <el-table-column header-align='center' align='center' prop="indoor_hygiene_score" label="屋内卫生得分" >
	   			 <template slot-scope="scope">{{scope.row.indoor_hygiene_score/2}}</template>
	   		 </el-table-column>
	   		 <el-table-column header-align='center' align='center' prop="outdoor_hygiene_score" label="屋外卫生得分" >
	   			 <template slot-scope="scope">{{scope.row.outdoor_hygiene_score/2}}</template>
	   		 </el-table-column>
	   		 <el-table-column  header-align='center' align='center' prop="outdoor_hygiene_score" label="当月得分" >
	   		 			 <template slot-scope="scope">{{scope.row.current_month_score}}</template>
	   		 </el-table-column>
	   		 <el-table-column header-align='center' align='center' prop="year_month" label="日期" ></el-table-column>
	   </el-table>
	   
	   
	<!-- 分页 -->
		<el-pagination v-show='totals>5' :page-size="5" style='margin-top: 40px;' background layout="prev, pager, next" @current-change="handleCurrentChange" :total="totals"></el-pagination>
    </el-dialog>
  </div>
</template>
<script>
import $ from 'jquery'
export default {
  name: 'stu',
  components: {},//声明子组件
  computed:{
		imgjoin(){//字符窜转数组
			 return function(i){
				   return i.split(",")
			 }
		 },
			  
		
	},
  data(){
	  return {
		logins:false,
		tableData:[],
		totals:0,
		pages:1,
		item:'',
		dialogTableVisible:false,//详情表格
		key_datas:[],
	    num:'',
	  }
  },
  methods:{
	  git_act(i,pages,num){
		  this.num = num;
		  let urls = '';
		    if(num == 1){
				urls = '/xf/point_pc/point_detail_list';
			}else if(num==2){
				urls = '/xf/point_pc/my_point_detail';
			}
		    
		     this.dialogTableVisible = true;
		     console.log(i,this.num,'父组件传递过来的数据');
			 // this.key_datas = item?item:this.key_datas;
			 this.item = i;
	  		 this.logins = true;
	  		 $.ajax({url:urls,type:'post',
	  		      data:{
	  				  family_id:this.item.family_id,
	  				  page:pages,
	  				  size:5,
	  			  },dataType:'json',success:(res)=> {
	  		 	      if(Object.prototype.toString.call(res) != '[object Object]'){res = JSON.parse(res)}
	  		 	      if(res.code==200){
	  		 			  this.tableData = res.data;
	  					  this.totals = res.count;
	  		 		  }else if(res.code==300){
	  					  this.$message.error('没有数据');
	  				  }
	  		 		  console.log(res,'详情');
					  this.logins = false;
	  		 	}
	  		 })
	  },
		
	  handleCurrentChange(val) {
	     console.log(`当前页: ${val}`);
	  		this.pages = val;
	  		this.git_act(this.item,this.pages);
	  },
	  selectimg(i){
			
		},
  },
  mounted(){
	  
  }
}
</script>
<style scoped="scoped">
</style>
